home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / frmcadgx.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-03-03  |  15.3 KB  |  530 lines

  1. VERSION 5.00
  2. Object = "{33B81F60-5683-42D6-8682-E4AE5FEADC5E}#1.0#0"; "TcViewer.ocx"
  3. Begin VB.Form frmCADGX 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "TurboCAD SDK Client sample application"
  6.    ClientHeight    =   7110
  7.    ClientLeft      =   30
  8.    ClientTop       =   270
  9.    ClientWidth     =   10590
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   7110
  14.    ScaleWidth      =   10590
  15.    StartUpPosition =   3  'Windows Default
  16.    Begin prjTcViewer.ctlTcViewer ctlTcViewer2 
  17.       Height          =   4812
  18.       Left            =   5760
  19.       TabIndex        =   29
  20.       Top             =   120
  21.       Width           =   4452
  22.       _ExtentX        =   7858
  23.       _ExtentY        =   8493
  24.    End
  25.    Begin prjTcViewer.ctlTcViewer ctlTcViewer1 
  26.       Height          =   4812
  27.       Left            =   480
  28.       TabIndex        =   28
  29.       Top             =   120
  30.       Width           =   4452
  31.       _ExtentX        =   7858
  32.       _ExtentY        =   8493
  33.    End
  34.    Begin VB.CommandButton btnSetAperture2 
  35.       Caption         =   "Set"
  36.       Height          =   300
  37.       Left            =   8760
  38.       TabIndex        =   27
  39.       Top             =   5268
  40.       Width           =   1428
  41.    End
  42.    Begin VB.CommandButton btnSetAperture1 
  43.       Caption         =   "Set"
  44.       Height          =   300
  45.       Left            =   3480
  46.       TabIndex        =   26
  47.       Top             =   5268
  48.       Width           =   1428
  49.    End
  50.    Begin VB.TextBox txtAperture2 
  51.       Height          =   288
  52.       Left            =   7968
  53.       TabIndex        =   24
  54.       Top             =   5280
  55.       Width           =   732
  56.    End
  57.    Begin VB.TextBox txtAperture1 
  58.       Height          =   288
  59.       Left            =   2688
  60.       TabIndex        =   22
  61.       Top             =   5268
  62.       Width           =   732
  63.    End
  64.    Begin VB.CommandButton btnNew2 
  65.       Caption         =   "New Drawing"
  66.       Height          =   372
  67.       Left            =   5772
  68.       TabIndex        =   21
  69.       Top             =   6096
  70.       Width           =   1452
  71.    End
  72.    Begin VB.CommandButton btnNew1 
  73.       Caption         =   "New Drawing"
  74.       Height          =   372
  75.       Left            =   468
  76.       TabIndex        =   20
  77.       Top             =   6132
  78.       Width           =   1452
  79.    End
  80.    Begin VB.CommandButton btnSpace2 
  81.       Height          =   252
  82.       Left            =   10200
  83.       TabIndex        =   19
  84.       Top             =   4920
  85.       Width           =   252
  86.    End
  87.    Begin VB.CommandButton btnSpace1 
  88.       Height          =   252
  89.       Left            =   240
  90.       TabIndex        =   18
  91.       Top             =   4920
  92.       Width           =   252
  93.    End
  94.    Begin VB.CommandButton btnZoomIn2 
  95.       Caption         =   "Zoom In"
  96.       Height          =   372
  97.       Left            =   5772
  98.       TabIndex        =   17
  99.       Top             =   5652
  100.       Width           =   1452
  101.    End
  102.    Begin VB.CommandButton btnZoomAll2 
  103.       Caption         =   "Zoom All"
  104.       Height          =   372
  105.       Left            =   7272
  106.       TabIndex        =   16
  107.       Top             =   5664
  108.       Width           =   1452
  109.    End
  110.    Begin VB.CommandButton btnZoomOut2 
  111.       Caption         =   "Zoom Out"
  112.       Height          =   372
  113.       Left            =   8772
  114.       TabIndex        =   15
  115.       Top             =   5676
  116.       Width           =   1452
  117.    End
  118.    Begin VB.CommandButton btnZoomIn1 
  119.       Caption         =   "Zoom In"
  120.       Height          =   372
  121.       Left            =   480
  122.       TabIndex        =   14
  123.       Top             =   5652
  124.       Width           =   1452
  125.    End
  126.    Begin VB.CommandButton btnZoomAll1 
  127.       Caption         =   "Zoom All"
  128.       Height          =   372
  129.       Left            =   3480
  130.       TabIndex        =   13
  131.       Top             =   5652
  132.       Width           =   1452
  133.    End
  134.    Begin VB.CommandButton btnZoomOut1 
  135.       Caption         =   "Zoom Out"
  136.       Height          =   372
  137.       Left            =   1980
  138.       TabIndex        =   12
  139.       Top             =   5652
  140.       Width           =   1452
  141.    End
  142.    Begin VB.CommandButton btnCopy21 
  143.       Caption         =   "<-"
  144.       Height          =   372
  145.       Left            =   5040
  146.       TabIndex        =   11
  147.       Top             =   2400
  148.       Width           =   612
  149.    End
  150.    Begin VB.CommandButton btncCopy12 
  151.       Caption         =   "->"
  152.       Height          =   372
  153.       Left            =   5040
  154.       TabIndex        =   10
  155.       Top             =   1920
  156.       Width           =   612
  157.    End
  158.    Begin VB.HScrollBar HScroll1 
  159.       Height          =   252
  160.       Left            =   480
  161.       Max             =   10
  162.       TabIndex        =   9
  163.       Top             =   4920
  164.       Value           =   5
  165.       Width           =   4452
  166.    End
  167.    Begin VB.HScrollBar HScroll2 
  168.       Height          =   252
  169.       Left            =   5760
  170.       Max             =   10
  171.       TabIndex        =   8
  172.       Top             =   4920
  173.       Value           =   5
  174.       Width           =   4452
  175.    End
  176.    Begin VB.VScrollBar VScroll2 
  177.       Height          =   4812
  178.       Left            =   10200
  179.       Max             =   10
  180.       TabIndex        =   7
  181.       Top             =   120
  182.       Value           =   5
  183.       Width           =   252
  184.    End
  185.    Begin VB.VScrollBar VScroll1 
  186.       Height          =   4812
  187.       Left            =   240
  188.       Max             =   10
  189.       TabIndex        =   6
  190.       Top             =   120
  191.       Value           =   5
  192.       Width           =   252
  193.    End
  194.    Begin VB.CommandButton btnSave2 
  195.       Caption         =   "Save Drawing"
  196.       Height          =   372
  197.       Left            =   7272
  198.       TabIndex        =   5
  199.       Top             =   6576
  200.       Width           =   1452
  201.    End
  202.    Begin VB.CommandButton btnClose2 
  203.       Caption         =   "Close Drawing"
  204.       Height          =   372
  205.       Left            =   8772
  206.       TabIndex        =   4
  207.       Top             =   6108
  208.       Width           =   1452
  209.    End
  210.    Begin VB.CommandButton btnOpen2 
  211.       Caption         =   "Open Drawing"
  212.       Height          =   372
  213.       Left            =   7272
  214.       TabIndex        =   3
  215.       Top             =   6096
  216.       Width           =   1452
  217.    End
  218.    Begin VB.CommandButton btnSave 
  219.       Caption         =   "Save Drawing"
  220.       Height          =   372
  221.       Left            =   1956
  222.       TabIndex        =   2
  223.       Top             =   6600
  224.       Width           =   1452
  225.    End
  226.    Begin VB.CommandButton btnClose1 
  227.       Caption         =   "Close Drawing"
  228.       Height          =   372
  229.       Left            =   3480
  230.       TabIndex        =   1
  231.       Top             =   6144
  232.       Width           =   1452
  233.    End
  234.    Begin VB.CommandButton btnOpen1 
  235.       Caption         =   "Open Drawing"
  236.       Height          =   372
  237.       Left            =   1968
  238.       TabIndex        =   0
  239.       Top             =   6132
  240.       Width           =   1440
  241.    End
  242.    Begin VB.Label Label2 
  243.       Caption         =   "Select  Aperture:"
  244.       Height          =   276
  245.       Left            =   6612
  246.       TabIndex        =   25
  247.       Top             =   5292
  248.       Width           =   1212
  249.    End
  250.    Begin VB.Label Label1 
  251.       Caption         =   "Select  Aperture:"
  252.       Height          =   216
  253.       Left            =   1332
  254.       TabIndex        =   23
  255.       Top             =   5280
  256.       Width           =   1212
  257.    End
  258. Attribute VB_Name = "frmCADGX"
  259. Attribute VB_GlobalNameSpace = False
  260. Attribute VB_Creatable = False
  261. Attribute VB_PredeclaredId = True
  262. Attribute VB_Exposed = False
  263. '******************************************************************'
  264. '*                                                                *'
  265. '*                      TurboCAD for Windows                      *'
  266. '*                   Copyright (c) 1993 - 2001                    *'
  267. '*             International Microcomputer Software, Inc.         *'
  268. '*                            (IMSI)                              *'
  269. '*                      All rights reserved.                      *'
  270. '*                                                                *'
  271. '******************************************************************'
  272. Option Explicit
  273. Dim gxApp As New XApplication
  274. Dim gxDwg1 As Drawing
  275. Dim gxDwg2 As Drawing
  276. Private Sub CloseDrawing1()
  277.     ctlTcViewer1.Detach
  278.     ctlTcViewer1.Refresh
  279.     If (Not gxDwg1 Is Nothing) Then
  280.         gxDwg1.Close
  281.         Set gxDwg1 = Nothing
  282.     End If
  283.     btnSpace1.Caption = ""
  284.     txtAperture1 = ""
  285. End Sub
  286. Private Sub CloseDrawing2()
  287.     ctlTcViewer2.Detach
  288.     ctlTcViewer2.Refresh
  289.     If (Not gxDwg2 Is Nothing) Then
  290.         gxDwg2.Close
  291.         Set gxDwg2 = Nothing
  292.     End If
  293.     btnSpace2.Caption = ""
  294.     txtAperture2 = ""
  295. End Sub
  296. Private Sub OpenDrawing1(strFilePath As String)
  297.     CloseDrawing1
  298.     If (strFilePath <> "") Then
  299.         Set gxDwg1 = gxApp.Drawings.Open(strFilePath)
  300.     Else
  301.         Set gxDwg1 = gxApp.Drawings.Add
  302.     End If
  303.     ctlTcViewer1.Attach gxDwg1
  304.     If (ctlTcViewer1.ViewSpace) Then
  305.         btnSpace1.Caption = "M"
  306.     Else
  307.         btnSpace1.Caption = "P"
  308.     End If
  309.     txtAperture1 = CStr(ctlTcViewer1.Aperture)
  310. End Sub
  311. Private Sub OpenDrawing2(strFilePath As String)
  312.     CloseDrawing2
  313.     On Error GoTo Err
  314.     If (strFilePath <> "") Then
  315.         Set gxDwg2 = gxApp.Drawings.Open(strFilePath)
  316.     Else
  317.         Set gxDwg2 = gxApp.Drawings.Add
  318.     End If
  319.     ctlTcViewer2.Attach gxDwg2
  320.     If (ctlTcViewer2.ViewSpace) Then
  321.         btnSpace2.Caption = "M"
  322.     Else
  323.         btnSpace2.Caption = "P"
  324.     End If
  325.     txtAperture2 = CStr(ctlTcViewer2.Aperture)
  326.     Exit Sub
  327.     If (Err.Number <> 0) Then
  328.         MsgBox Err.Description
  329.     End If
  330. End Sub
  331. Private Sub btncCopy12_Click()
  332.     Dim gxGrSel As Graphic
  333.     Dim gxSel As Selection
  334.     On Error GoTo ErrHandler
  335.     ctlTcViewer2.Update = False
  336.     Set gxSel = gxDwg1.Selection
  337.     For Each gxGrSel In gxSel
  338.         MergeGraphic gxGrSel, gxDwg1, gxDwg2
  339.     Next gxGrSel
  340. ErrHandler:
  341.     ctlTcViewer2.Update = True
  342.     Set gxGrSel = Nothing
  343.     Set gxSel = Nothing
  344. End Sub
  345. Private Sub btnClose1_Click()
  346.     CloseDrawing1
  347. End Sub
  348. Private Sub btnClose2_Click()
  349.     CloseDrawing2
  350. End Sub
  351. Private Sub btnCopy21_Click()
  352.     Dim gxGrSel As Graphic
  353.     Dim gxSel As Selection
  354.     ctlTcViewer1.Update = False
  355.     Set gxSel = gxDwg2.Selection
  356.     For Each gxGrSel In gxSel
  357.         MergeGraphic gxGrSel, gxDwg2, gxDwg1
  358.     Next gxGrSel
  359.     ctlTcViewer1.Update = True
  360. ErrHandler:
  361.     Set gxGrSel = Nothing
  362.     Set gxSel = Nothing
  363. End Sub
  364. Private Sub btnNew1_Click()
  365.     OpenDrawing1 ""
  366. End Sub
  367. Private Sub btnNew2_Click()
  368.     OpenDrawing2 ""
  369. End Sub
  370. Private Sub btnOpen1_Click()
  371.     On Error GoTo Err
  372.     OpenDrawing1 gxApp.GetOpenFilename
  373. End Sub
  374. Private Sub btnOpen2_Click()
  375.     On Error GoTo Err
  376.     OpenDrawing2 gxApp.GetOpenFilename
  377. End Sub
  378. Private Sub btnSave_Click()
  379.     On Error GoTo Err
  380.     gxDwg1.SaveAs gxApp.GetSaveFilename
  381. End Sub
  382. Private Sub btnSave2_Click()
  383.     On Error GoTo Err
  384.     gxDwg2.SaveAs gxApp.GetSaveFilename
  385. End Sub
  386. Private Sub btnSetAperture1_Click()
  387.     On Error Resume Next
  388.     ctlTcViewer1.Aperture = CDbl(txtAperture1)
  389. End Sub
  390. Private Sub btnSetAperture2_Click()
  391.     On Error Resume Next
  392.     ctlTcViewer2.Aperture = CDbl(txtAperture2)
  393. End Sub
  394. Private Sub btnSpace1_Click()
  395.     On Error GoTo ErrHandler
  396.     If (ctlTcViewer1.ViewSpace) Then
  397.         btnSpace1.Caption = "P"
  398.         ctlTcViewer1.ViewSpace = 0
  399.     Else
  400.         btnSpace1.Caption = "M"
  401.         ctlTcViewer1.ViewSpace = 1
  402.     End If
  403.     ctlTcViewer1.Zoom 0
  404.     ctlTcViewer1.Refresh
  405. ErrHandler:
  406. End Sub
  407. Private Sub btnSpace2_Click()
  408.     On Error GoTo ErrHandler
  409.     If (ctlTcViewer2.ViewSpace) Then
  410.         btnSpace2.Caption = "P"
  411.         ctlTcViewer2.ViewSpace = 0
  412.     Else
  413.         btnSpace2.Caption = "M"
  414.         ctlTcViewer2.ViewSpace = 1
  415.     End If
  416.     ctlTcViewer2.Zoom 0
  417.     ctlTcViewer2.Refresh
  418. ErrHandler:
  419. End Sub
  420. Private Sub btnZoomAll1_Click()
  421.     ctlTcViewer1.Zoom 0
  422.     ctlTcViewer1.Refresh
  423. End Sub
  424. Private Sub btnZoomIn1_Click()
  425.     ctlTcViewer1.Zoom 1 / 1.25
  426.     ctlTcViewer1.Refresh
  427. End Sub
  428. Private Sub btnZoomOut1_Click()
  429.     ctlTcViewer1.Zoom 1.25
  430.     ctlTcViewer1.Refresh
  431. End Sub
  432. Private Sub btnZoomAll2_Click()
  433.     ctlTcViewer2.Zoom 0
  434.     ctlTcViewer2.Refresh
  435. End Sub
  436. Private Sub btnZoomIn2_Click()
  437.     ctlTcViewer2.Zoom 1 / 1.25
  438.     ctlTcViewer2.Refresh
  439. End Sub
  440. Private Sub btnZoomOut2_Click()
  441.     ctlTcViewer2.Zoom 1.25
  442.     ctlTcViewer2.Refresh
  443. End Sub
  444. Private Sub ctlTcViewer1_ClickGraphic(gxGr As IMSIGX.IGraphic, dist As Double)
  445.     Dim gxGrSel As Graphic
  446.     Dim gxSel As Selection
  447.     Set gxSel = gxDwg1.Selection
  448.     For Each gxGrSel In gxSel
  449.         If (gxGrSel.ID = gxGr.ID) Then
  450.             gxGrSel.Unselect
  451.             GoTo Done
  452.         End If
  453.     Next gxGrSel
  454.     'don't select graphic if it belongs to non-editable layer
  455.     Dim gxLyr As Layer
  456.     Set gxLyr = gxGr.Layer
  457.     If gxLyr.Editable Then
  458.         gxGr.Select
  459.     End If
  460. Done:
  461.     Set gxGrSel = Nothing
  462.     Set gxSel = Nothing
  463. End Sub
  464. Private Sub ctlTcViewer2_ClickGraphic(gxGr As IMSIGX.IGraphic, dist As Double)
  465.     Dim gxGrSel As Graphic
  466.     Dim gxSel As Selection
  467.     Set gxSel = gxDwg2.Selection
  468.     For Each gxGrSel In gxSel
  469.         If (gxGrSel.ID = gxGr.ID) Then
  470.             gxGrSel.Unselect
  471.             GoTo Done
  472.         End If
  473.     Next gxGrSel
  474.     'don't select graphic if it belongs to non-editable layer
  475.     Dim gxLyr As Layer
  476.     Set gxLyr = gxGr.Layer
  477.     If gxLyr.Editable Then
  478.         gxGr.Select
  479.     End If
  480. Done:
  481.     Set gxGrSel = Nothing
  482.     Set gxSel = Nothing
  483. End Sub
  484. Private Sub Form_Terminate()
  485.     CloseDrawing1
  486.     CloseDrawing2
  487.     Set gxApp = Nothing
  488. End Sub
  489. Private Sub Form_Unload(Cancel As Integer)
  490.     CloseDrawing1
  491.     CloseDrawing2
  492.     Set gxApp = Nothing
  493. End Sub
  494. Private Sub HScroll1_Change()
  495.     Dim dx As Long
  496.     dx = HScroll1.Value - 5
  497.     If (dx <> 0) Then
  498.         ctlTcViewer1.Scroll 0, dx
  499.         HScroll1.Value = 5
  500.     End If
  501.     ctlTcViewer1.Refresh
  502. End Sub
  503. Private Sub VScroll1_Change()
  504.     Dim dy As Long
  505.     dy = VScroll1.Value - 5
  506.     If (dy <> 0) Then
  507.         ctlTcViewer1.Scroll dy, 0
  508.         VScroll1.Value = 5
  509.     End If
  510.     ctlTcViewer1.Refresh
  511. End Sub
  512. Private Sub HScroll2_Change()
  513.     Dim dx As Long
  514.     dx = HScroll2.Value - 5
  515.     If (dx <> 0) Then
  516.         ctlTcViewer2.Scroll 0, dx
  517.         HScroll2.Value = 5
  518.     End If
  519.     ctlTcViewer2.Refresh
  520. End Sub
  521. Private Sub VScroll2_Change()
  522.     Dim dy As Long
  523.     dy = VScroll2.Value - 5
  524.     If (dy <> 0) Then
  525.         ctlTcViewer2.Scroll dy, 0
  526.         VScroll2.Value = 5
  527.     End If
  528.     ctlTcViewer2.Refresh
  529. End Sub
  530.